import dayjs from "dayjs";
const dateFormat = "YYYY-MM-DD";
const toString = Object.prototype.toString;
export const momentToTime = (obj: any) => {
  const temp: any = {};
  for (const k in obj) {
    const val = obj[k];
    temp[k] = val;

    if ("[object Array]" === toString.call(val)) {
      if (val[0] && val[0].$y) {
        const [first, second] = val;
        temp[k] = [
          dayjs(first).format(dateFormat),
          dayjs(second).format(dateFormat),
        ];
      }
    } else if (val && val.$y) {
      temp[k] = dayjs(val).format(dateFormat);
    }
  }
  return temp;
};
